
// Color contrast
@function color-yiq($color) {
    $r: red($color);
    $g: green($color);
    $b: blue($color);

    $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

    @if ($yiq >= $yiq-contrasted-threshold) {
        @return $yiq-text-dark;
    } @else {
        @return $yiq-text-light;
    }
}

// Color contrast
@function color-nyiq($color) {
    $r: red($color);
    $g: green($color);
    $b: blue($color);

    $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

    @if ($yiq >= $yiq-contrasted-threshold) {
        @return $yiq-text-light;
    } @else {
        @return $yiq-text-dark;
    }
}
